package com.cwd.arm.infrastructure.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.cwd.arm.infrastructure.dao.ProjectMonthAmountTotalDao;
import com.cwd.arm.infrastructure.dao.base.DaoImpl;
import com.cwd.arm.infrastructure.mapper.ProjectMonthAmountTotalMapper;
import com.cwd.arm.infrastructure.po.ProjectMonthAmountTotalPo;
import com.cwd.arm.infrastructure.query.ProjectMonthAmountTotalDaoQuery;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Description:项目每月统计
 * Created on 2021年11月16日
 *
 * @author yan
 */
@Service
public class ProjectMonthAmountTotalDaoImpl extends DaoImpl<ProjectMonthAmountTotalMapper, ProjectMonthAmountTotalPo> implements ProjectMonthAmountTotalDao {

    @Override
    public List<ProjectMonthAmountTotalPo> selectByQuery(ProjectMonthAmountTotalDaoQuery daoQuery) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq(ObjectUtils.isNotEmpty(daoQuery.getProjectId()), "project_id", daoQuery.getProjectId());
        queryWrapper.eq(ObjectUtils.isNotEmpty(daoQuery.getFyYear()),"fy_year",daoQuery.getFyYear());
//        queryWrapper.eq(ObjectUtils.isNotEmpty(daoQuery.getFyYear()),"fy_year",daoQuery.getFyYear());
        return list(queryWrapper);
    }

    @Override
    public ProjectMonthAmountTotalPo selectOne(Long projectId, Integer year, Integer month) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("project_id",projectId);
        queryWrapper.eq("fy_year",year);
        queryWrapper.eq("fy_month",month);
        return getOne(queryWrapper);
    }
}
